﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AreaManage_List.aspx.cs" Inherits="BaseData_AreaManage_List" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
  <title>组织树展示</title>
    <link rel="stylesheet" href="../css/css.css"  type="text/css" />
 <script language ="javascript" type="text/javascript" >
    <!--  

function ck(obj,obj1){
if(obj.lowsrc=="") return true;
obj.imgRolln=obj.src;
obj.src=obj.lowsrc;
obj.lowsrc=obj.imgRolln;
if(obj1.style.display=='none')
   obj1.style.display='';
else
   obj1.style.display='none';
}

var GOrgInfo      = "" ;  //上级组织ID的集合;
var ParentOrgIDCol     = "";   //得到上级组织ID集合 
var ChildOrgIDCol = "" ; //所有子部门的集合;
//显示树型
function show_tree(space_c,ParentID)
{
  var i,j,k,img_src1,img_src2; 
  for(k=0;k<trees.length;k++)
  {
    if(trees[k].ParentID == ParentID)
    {      
      document.write("<table border=0 cellspacing=0 cellpadding=0 bordercolor=#000000 width=100%><tr><form action=\"Default.aspx\" name=\"form1\" method=\"post\"><td>");
      
      for(i=1;i<=space_c;i++)
        document.write("&nbsp;&nbsp;");
      //alert(GOrgInfo);
      if(GOrgInfo!="")
      {
        if(trees[k].ID != ParentID)
        {
             //alert(trees[k].Name);
           img_src1="../sysmanage/img/sys/close.gif";
           img_src2="../sysmanage/img/sys/open.gif";
        } 
        var ary  = GOrgInfo.split(',');
        var nary = ary.length;
        for(i=0;i<nary-1;i++)
        { 
          if(trees[k].ID == ary[i])
          {
            //alert(ary[i]+","+ParentID);
            img_src1="../sysmanage/img/sys/open.gif";
            img_src2="../sysmanage/img/sys/close.gif";
          }
          if(trees[k].ParentID == ary[i])
          {  //alert(ary[i]+","+ParentID);
             img_src1="../sysmanage/img/sys/close.gif";
             img_src2="../sysmanage/img/sys/open.gif";
           }             
        }
        
      }
      else
      {
           img_src1="../sysmanage/img/sys/close.gif";           
           img_src2="../sysmanage/img/sys/open.gif";           
      }
      if(trees[k].ChildNumber=="0")
        img_src1="../sysmanage/img/sys/open.gif";
      if(trees[k].ChildNumber=="0")
        img_src2="../sysmanage/img/sys/open.gif";

      document.write("<img lowsrc=" + img_src2 + "  id=\"img_"+trees[k].ID+"\" onclick=\"ck(this,document.all.T" + trees[k].ID + ");\" src=" + img_src1 + " align=middle><a  style=\"cursor:pointer\" onclick=\"tog(this,'#f3f3f3');sendCtrlNodeInfo('" + trees[k].ID + "','" + trees[k].Name + "','" + trees[k].ParentID + "','" + trees[k].ChildNumber +"'); \" >&nbsp;" + trees[k].Name + "</a></td></form></tr></table>");
    
      document.write ("<span id='T" + trees[k].ID + "' style='display:none'>" );
      if(trees[k].ChildNumber != "0")
        show_tree(space_c +1 ,trees[k].ID);
      document.write ("</span>");
    }
  }
}

function sendCtrlNodeInfo(sID,sName,sParentID,sChildNumber)
{
    hidform.hOrgID.value = sID;
    hidform.hParentID.value = sParentID;
    hidform.hOrgName.value = sName;
    hidform.hParentChildIDCol.value = ChildOrgIDCol + sID ;
    hidform.hOrgInfo.value = sID + "|" + sName + "|" + sParentID;
}

//展开收缩下一级部门
function SpreadNextOrgTree(DeptID,ChildNum)
{
  var i,j,k,img_src1,img_src2;
  if(ChildNum!="0")
  {
    if(eval("document.all.T"+DeptID+".style.display")=='none')
    {
      eval("document.all.T"+DeptID+".style.display=''");    //展开下级层
      eval("document.all.img_"+DeptID+".src=\"img/sys/open.gif\";");    //展开下级层
      eval("document.all.img_"+DeptID+".lowsrc=\"img/sys/close.gif\";");    //展开下级层
    }
    else
    {
      eval("document.all.T"+DeptID+".style.display='none'");    //收缩下级层
      eval("document.all.img_"+DeptID+".src=\"img/sys/close.gif\";");    //收缩下级层
      eval("document.all.img_"+DeptID+".lowsrc=\"img/sys/open.gif\";");    //收缩下级层
    }
  }
}

//取得当前组织的上级组织ID的集合
function GetParentOrgID(OrgID)
{
  var k;
  ParentOrgIDCol = "";
  for(k=0;k<trees.length;k++)
  {
    var TempStr1 = "";
    if(trees[k].ID == OrgID)   //当前组织的ID
    {
      TempStr1 = TempStr1 + trees[k].ID + ",";
      GetParentOrgID(trees[k].ParentID);
      ParentOrgIDCol = ParentOrgIDCol + TempStr1 ;
    }
  }
}

//取得当前组织直属下级组织ID集合
function GetChildOrgID(OrgID)
{
  var k;
  //ChildOrgIDCol="";
  for(k=0;k<trees.length;k++)
  {
    var TempStr2 = "";
    if(trees[k].ParentID == OrgID)   //当前组织的ID
    {
      TempStr2 = TempStr2 + trees[k].ID + ",";
      GetChildOrgID(trees[k].ID);
      ChildOrgIDCol = ChildOrgIDCol + TempStr2 ;
    }    
  }
}


//自动展开新组织的所有上级组织  OrgID是要展开的组织\
function GetSuperOrgID(OrgID)   //取得上级部门ID的集合.为展开树做准备的.
{
  var k;
  for(k=0;k<trees.length;k++)
  {
    var TempStr = "";
    if(trees[k].ParentID == "0")
    {
        break;
    }
    if(trees[k].ID == OrgID)   //当前组织的ID
    {
      TempStr = TempStr + trees[k].ID + ",";
      GetSuperOrgID(trees[k].ParentID);
      GOrgInfo = GOrgInfo + TempStr ;
    }    
  }
}

//展开一个新树

function SpreadNewOrgTree()
{  
  var i,j,k,img_src1,img_src2;
      if(GOrgInfo!="")
      {
        var ary  = GOrgInfo.split(',');
        var nary = ary.length;
        for(i=0;i<nary-1;i++)
        {
          eval("document.all.T"+ary[i]+".style.display=''");
        } 
      }
      else
      {
        //alert(GOrgInfo);
      }
}

var tgs; 
var tmp_background_val; 
function tog(n,flags)
{ 
  if (tgs)
  { 
    tgs.style.background= tmp_background_val ; 
  } 
  n.style.background= '#99ccff'; 
  tmp_background_val=flags;
  tgs=n; 
} 
-->
    </script>
    </head> 
    <body style =" background-image :url('../images/hit_bg.gif');">
    <% 
  Response .ExpiresAbsolute=System.DateTime.Now. AddSeconds(-1);
  Response.Expires=0;
  Response.CacheControl = "no-cache";
%>
      <table cellpadding ="0" cellspacing ="0" width="98%" align="center" >
       <tr>       
        <td><%=sHtml %></td>        
       </tr>
      </table> 
      <form id = "hidform" method="post" runat ="server">
        <input type="hidden" id="hOrgInfo" runat ="server" />
        <input type="hidden" id="hOrgID" runat ="server" />
        <input type="hidden" id="hParentID" runat ="server" />
        <input type="hidden" id="hChildNumber" runat ="server" />
        <input type="hidden" id="hOrgName" runat ="server" />
        <input type="hidden" id="hOrgType" runat ="server" />
        <input type="hidden" id="hParentChildIDCol" runat ="server" />
        <input type="hidden" id="hEffective" runat ="server" />

        <asp:Button ID="BtnDel" runat="server" Text="Button" Width="0px" Height="0px" OnClick="BtnDel_Click"  />

        <asp:Button ID="BtnRefresh1" runat="server" Text="Button" Width="0px" Height="0px" OnClick="BtnRefresh_Click"  />
        <asp:Button ID="BtnRefresh2" runat="server" Text="Button" Width="0px" Height="0px" OnClick="BtnRefresh2_Click"  />

      </form>
  </body>
</html>